package com.example.myblog.result;

import lombok.Data;

@Data
public class ResponseBean<T> {
    private boolean success;
    private T data;

    public static <T> ResponseBean<T> success(T data){
        ResponseBean<T> responseBean = new ResponseBean<>();
        responseBean.setSuccess(true);
        responseBean.setData(data);
        return responseBean;
    }

    public static <T> ResponseBean<T> error(T errorData){
        ResponseBean<T> responseBean = new ResponseBean<>();
        responseBean.setSuccess(false);
        responseBean.setData(errorData);
        return responseBean;
    }

    public static <T> ResponseBean<T> success(){
        ResponseBean<T> responseBean = new ResponseBean<>();
        responseBean.setSuccess(true);
        return responseBean;
    }

}
